/*
 * @Author: 黄达全
 * @Date: 2024-08-04 14:18:57
 * @LastEditTime: 2024-08-11 20:41:14
 */
/*
 * @Author: 黄达全
 * @Date: 2024-08-04 14:18:57
 * @LastEditTime: 2024-08-05 14:39:34
 */
import { ApiResponse } from "./http";
import { LoginVO, LoginForm } from "./login";

// 用户菜单权限
export interface MenuItem {
    id: number;
    rule_id: number;
    status: number;
    create_time: string;
    update_time: string;
    name: string;
    desc: string;
    frontpath: null;
    condition: null;
    menu: number;
    order: string;
    icon: string;
    method: string;
    child: MenuItem[] | [];
}

// 用户信息
export type ManagerInfoVO = {
    id: number,
    username: string,
    avatar: string,
    isSuper: number,
    role: {
        id: number,
        name: string
    },
    menus: MenuItem[] | [],
    ruleNames: string[] | []
}

// 查询
export type ManagerPageVO = {
    total: number,
    records: ManagerVO[]
}

export type ManagerVO = {
    id: number,
    username: string,
    avatar: string,
    roleId: number,
    rolename: string,
    desc: string,
    isSuper: number,
    status: number,
    create_time: string,
    update_time: string,
    create_manager_id: number,
    last_update_manager_id: number,
    create_manager_name: string,
    last_update_manager_name: string,
}

export type ManagerXiaLaVO = {
    id: number,
    username: string
}
export type ManagerXiaLaOptions = {
    value: number,
    label: string
}

// 过滤表单
export type ManagerFilterForm = {
    username: string | null,
    status: number | null,
    roleId: number | null,
    createManagerId: number | null,
    lastUpdateManagerId: number | null
}


// 新增
export type ManagerAddForm = {
    username: string | null,
    password: string | null,
    avatar: string,
    roleId: number | null,
    status: boolean
}
// 修改
export type ManagerUpdateForm = {
    username: string,
    password: string,
    avatar: string,
    roleId: number | null,
    status: boolean
}



export type ManagerApi = {
    login: (data: LoginForm) => Promise<ApiResponse<LoginVO>>,
    getUserInfo: () => Promise<ApiResponse<ManagerInfoVO>>,
    logout: () => Promise<ApiResponse<null>>,
    page: (page: number, pageSize: number, form?: ManagerFilterForm) => Promise<ApiResponse<ManagerPageVO>>,
    add: (form: ManagerAddForm) => Promise<ApiResponse<null>>,
    update: (id: number, form: ManagerUpdateForm) => Promise<ApiResponse<null>>,
    delete: (ids: number[]) => Promise<ApiResponse<null>>,
    banned: (ids: number[], status: number) => Promise<ApiResponse<null>>,
    selectXiaLa: () => Promise<ApiResponse<ManagerXiaLaVO[]>>
}
